package com.example.yuanqin.page.login

import android.util.Log
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.*
import androidx.compose.material.*
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateListOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.example.yuanqin.TAG

sealed class SignInEvent {
    object SignIn:SignInEvent()
}


@Preview
@Composable
fun signInScreenPre(){
    MaterialTheme(
        colors = MaterialTheme.colors,
    ) {
        signInScreen{
            
        }
    }
}

@Composable
fun signInScreen(onEvent: (SignInEvent) -> Unit){
    Column(modifier = Modifier
        .background(Color.White)
        .fillMaxWidth()
        .fillMaxHeight()
        .padding(35.dp)) {
        var loginInfo = remember {
            mutableStateListOf("","")
        }

        TextField(value = loginInfo[0], 
            onValueChange = {loginInfo[0] = it},
            label = { Text(text = "用户名")},
            modifier = Modifier.fillMaxWidth()
        )
        Spacer(modifier = Modifier.size(0.dp,35.dp))

        TextField(value = loginInfo[1],
            onValueChange = {loginInfo[1] = it},
            label = { Text(text = "密码")},
            modifier = Modifier.fillMaxWidth()
        )
        Spacer(modifier = Modifier.size(0.dp,35.dp))

        Text(text = "忘记密码?",color = Color.Blue,
            fontSize = 13.sp,
            modifier = Modifier
                .fillMaxWidth()
                .wrapContentWidth(Alignment.End)
                .clickable { Log.e(TAG, "signInScreen: 点击忘记了密码", ) }
        )
        Spacer(modifier = Modifier.size(0.dp,35.dp))

        Button(onClick = { onEvent(SignInEvent.SignIn) },
            modifier = Modifier
                .fillMaxWidth()
                .height(55.dp),
        ) {
            Text(text = "登录",color = Color.White,fontSize = 22.sp)
        }


    }
}
